package view;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;

/**
 * Class to close the a GUI view in our application.
 * @author Sarah George
 * @version Autumn 2012
 */
@SuppressWarnings("serial")
public class CloseAction extends AbstractAction {

	/**
	 * Field to hold a reference to the current JFrame.
	 */
	private final JFrame my_frame;

	/**
	 * Constructs a clear action.
	 * @param the_frame the JFrame affected by this class.
	 */
	public CloseAction(final JFrame the_frame) {
		super("Quit");
		my_frame = the_frame;
		putValue(Action.MNEMONIC_KEY, KeyEvent.VK_Q);
		putValue(Action.SELECTED_KEY, true);
	}

	/**
	 * Method to clear the drawing panel.
	 * @param the_event the action event, either mouse click or keyboard shortcut.
	 */
	@Override
	public void actionPerformed(final ActionEvent the_event) {
		my_frame.dispose();
	}
} //End class close action.